package com.sufen.seckill.study.LeetCode;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author sufen
 * @Date 2021/11/4 16:03
 * @Version 1.0
 * 功能描述：
 */
public class Offer_03_数组中重复的数字 {
    public static void main(String[] args) {
        int[] input={1,2,3,4,5,6,3,7,8};
        System.out.println(findRepeatNumber(input));

    }
    private static int findRepeatNumber(int[] nums) {
        Set<Integer> set=new HashSet<>();
        for(int numTmp:nums){
            if(set.contains(numTmp)){
                return numTmp;
            }else{
                set.add(numTmp);
            }
        }
        return 0;
    }
}
